package app.Disthanitian.thaistyle.EmerMez;

import java.util.ArrayList;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class ListRiskZoneAdapter extends BaseAdapter {
 
    private ArrayList<RiskZone> riskArea;
    Context c;
    String check;
    ListRiskZoneAdapter (ArrayList<RiskZone> data, Context c){
        this.riskArea = data;
        this.c = c;
    }
   
    public int getCount() {
        // TODO Auto-generated method stub
        return riskArea.size();
    }
    
 
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return riskArea.get(position);
    }
 
    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }
   
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
         View v = convertView;
         if (v == null)
         {
            LayoutInflater vi = (LayoutInflater) c.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.list_row_riskzone, null);
         }
 
           ImageView image = (ImageView) v.findViewById(R.id.list_image);
           TextView title = (TextView)v.findViewById(R.id.title);
           TextView nickName = (TextView)v.findViewById(R.id.nickname);
           TextView enable = (TextView)v.findViewById(R.id.enable);
          
           RiskZone r = riskArea.get(position);           
           image.setImageResource(R.drawable.riskzone_central);
           title.setText(r.getNameStart()+" "+r.getNameEnd());
           nickName.setText(r.getNickName());
           if(r.getEnable().equals("T"))
        	   check = "Enable";
           else
        	   check = "Disable";           
           enable.setText(check);                             
                        
        return v;
}
}